<template>
  <div
    v-if="isSelfFun()"
    class="pull-right color-red"
    style="line-height: inherit"
    @click="deleteFriendCircle"
  >
    删除
  </div>
</template>

<script>
export default {
  props: ["currentUserInfo", "index", "data"],
  name: "redfriendscircleDeleteComponent",
  data() {
    return {};
  },
  created() {},
  mounted() {},
  methods: {
    /**
     * 判断是否为本人的个人盆友圈
     * 1、type为2
     * 2、用户ID相等
     */
    isSelfFun() {
      // let type = this.$route.query.type
      let data = this.data;
      let myInfo = this.tools.getUserInfo();
      return myInfo.id == data.userId;
      // return type == 2 && myInfo.id === currentUserInfo.id
    },
    /**
     * 删除动态，并删除列表
     */
    deleteFriendCircle() {
      let me = this;
      this.$createDialog({
        type: "confirm",
        title: "确定删除？",
        content: "",
        confirmBtn: {
          text: "确定",
          active: true,
          disabled: false,
          href: "javascript:;",
        },
        cancelBtn: {
          text: "取消",
          active: false,
          disabled: false,
          href: "javascript:;",
        },
        onConfirm: () => {
          let params = {
            id: this.data.id,
          };
          this.fetchService.friendNewsDelete(params).then((res) => {
            if (res.code !== 0) {
              return this.tools.tip(res.message);
            }
            this.tools.tip("删除成功");
            this.$store.state.redfriendscircleList.splice(this.index, 1);
          });
        },
        onCancel: () => {},
      }).show();
    },
  },
};
</script>

<style scoped lang="scss">
@import "@/common/stylus/moon.scss";
</style>

